package main

import (
	"bufio"
	"fmt"
	"os"
)

/**
 * @author: guangcheng
 * @date:   2020/11/26 15:11
 * @version  V1.0
 * @description:
 *
 */
func main() {

	filePaht := "d:/gofilewrite.txt"
	file, err := os.OpenFile(filePaht, os.O_WRONLY|os.O_CREATE, 0666)
	if err != nil {
		fmt.Printf("open file err=%v\n", err)
		return
	}

	//
	defer file.Close()
	//
	str := "hello,atguigu\r\n"
	//
	writer := bufio.NewWriter(file)
	for i := 0; i < 10; i++ {
		writer.WriteString(str)
	}

	//冲出去才行
	writer.Flush()
}
